#!/usr/bin/env python2.7

# noteparser.py

import os, sys
#import re
#from datetime import datetime, timedelta
#from dateutil.parser import parse
#import numpy as np
#import pandas as pd
#import matplotlib
#matplotlib.use('Agg')
#import matplotlib.pyplot as plt
#from mpl_toolkits.basemap import Basemap
#from matplotlib import mlab
#from netCDF4 import Dataset
from metlib.kits import *

def loadcmpnote(fn):
    res = {}
    with open(fn) as f:
        for line in f:
            line = line.strip()
            if len(line) == 0 or line.startswith('#'):
                continue
            dtstr, note = line.split(':')
            if note == 'NC':
                res[dtstr] = (Null, Null)
            else:
                l1, l2 = ['L'+tk for tk in note.split(';')]
                res[dtstr] = (l1, l2)
    return res

def loadnote(fn, method='list'):
    if method == 'list':
        res = []
    elif method == 'dict':
        res = {}
    with open(fn) as f:
        for line in f:
            line = line.strip()
            if len(line) == 0 or line.startswith('#'):
                continue
            dtstr, note = line.split(':')
            if method == 'list':
                res.append((dtstr, note))
            elif method == 'dict':
                res[dtstr] = note
    return res

if __name__ == '__main__':
    pass
